package org.game.minesweeper;

import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
import lombok.extern.slf4j.Slf4j;
import org.game.constant.APIConstant;
import org.game.support.StopApp;
import org.game.util.MapUtil;
import org.game.util.YamlUtil;

import java.util.Map;

@Slf4j
public class MinesweeperApp extends StopApp {

    @Override
    public void start(Stage primaryStage) throws Exception {
        Map<String, Object> config = YamlUtil.read(MinesweeperApp.class);

        MapUtil.cloneMap(APIConstant.CONFIG, config);

        Parent root = FXMLLoader.load(getClass().getResource("/fxml/minesweeperFxml.fxml"));
        primaryStage.setTitle((String) config.get("title"));
        primaryStage.setScene(new Scene(root,
                (Integer) APIConstant.CONFIG.get("width") * (Integer) APIConstant.CONFIG.get("cellWidth") + 20,
                (Integer) APIConstant.CONFIG.get("height") * (Integer) APIConstant.CONFIG.get("cellHeight") + 120));
        primaryStage.show();
    }


    public static void main(String[] args) {
        launch(args);
    }
}
